/*
 * @Author: Wangjun
 * @Date: 2023-08-18 19:24:32
 * @LastEditTime: 2023-09-22 11:00:31
 * @LastEditors: Wangjun
 * @Description:
 * @FilePath: \xr_node_calc\kafka\kafka.go
 * hnxr
 */
package kafka

import (
	"strings"

	"gitee.com/haodreams/golib/logs"
	"gitee.com/haodreams/libs/config"
	"github.com/twmb/franz-go/pkg/kgo"
)

/**
 * @description: kafka生产者
 * @return {*}
 */
func NewWriter() *kgo.Client {
	host := config.String("kafka.hosts.producer")
	brokers := strings.Split(host, ",")

	opts := []kgo.Opt{
		kgo.SeedBrokers(brokers...),
	}

	cl, err := kgo.NewClient(opts...)
	if err != nil {
		logs.Warn(err)
		return nil
	}
	return cl
}
